package com.zzxx.mapper;

import com.zzxx.entity.Coupon;
import com.zzxx.entity.CouponExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface CouponMapper extends CouponMapperEx{
    @SelectProvider(type=CouponSqlProvider.class, method="countByExample")
    long countByExample(CouponExample example);

    @DeleteProvider(type=CouponSqlProvider.class, method="deleteByExample")
    int deleteByExample(CouponExample example);

    @Delete({
        "delete from coupon",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int deleteByPrimaryKey(String id);

    @Insert({
        "insert into coupon (id, name, ",
        "type, number, indate, ",
        "lastNum, introduce, ",
        "targetId, src)",
        "values (#{id,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, ",
        "#{type,jdbcType=INTEGER}, #{number,jdbcType=DOUBLE}, #{indate,jdbcType=INTEGER}, ",
        "#{lastnum,jdbcType=INTEGER}, #{introduce,jdbcType=VARCHAR}, ",
        "#{targetid,jdbcType=VARCHAR}, #{src,jdbcType=VARCHAR})"
    })
    int insert(Coupon row);

    @InsertProvider(type=CouponSqlProvider.class, method="insertSelective")
    int insertSelective(Coupon row);

    @SelectProvider(type=CouponSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
        @Result(column="number", property="number", jdbcType=JdbcType.DOUBLE),
        @Result(column="indate", property="indate", jdbcType=JdbcType.INTEGER),
        @Result(column="lastNum", property="lastnum", jdbcType=JdbcType.INTEGER),
        @Result(column="introduce", property="introduce", jdbcType=JdbcType.VARCHAR),
        @Result(column="targetId", property="targetid", jdbcType=JdbcType.VARCHAR),
        @Result(column="src", property="src", jdbcType=JdbcType.VARCHAR)
    })
    List<Coupon> selectByExample(CouponExample example);

    @Select({
        "select",
        "id, name, type, number, indate, lastNum, introduce, targetId, src",
        "from coupon",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="name", property="name", jdbcType=JdbcType.VARCHAR),
        @Result(column="type", property="type", jdbcType=JdbcType.INTEGER),
        @Result(column="number", property="number", jdbcType=JdbcType.DOUBLE),
        @Result(column="indate", property="indate", jdbcType=JdbcType.INTEGER),
        @Result(column="lastNum", property="lastnum", jdbcType=JdbcType.INTEGER),
        @Result(column="introduce", property="introduce", jdbcType=JdbcType.VARCHAR),
        @Result(column="targetId", property="targetid", jdbcType=JdbcType.VARCHAR),
        @Result(column="src", property="src", jdbcType=JdbcType.VARCHAR)
    })
    Coupon selectByPrimaryKey(String id);

    @UpdateProvider(type=CouponSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("row") Coupon row, @Param("example") CouponExample example);

    @UpdateProvider(type=CouponSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("row") Coupon row, @Param("example") CouponExample example);

    @UpdateProvider(type=CouponSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Coupon row);

    @Update({
        "update coupon",
        "set name = #{name,jdbcType=VARCHAR},",
          "type = #{type,jdbcType=INTEGER},",
          "number = #{number,jdbcType=DOUBLE},",
          "indate = #{indate,jdbcType=INTEGER},",
          "lastNum = #{lastnum,jdbcType=INTEGER},",
          "introduce = #{introduce,jdbcType=VARCHAR},",
          "targetId = #{targetid,jdbcType=VARCHAR},",
          "src = #{src,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=VARCHAR}"
    })
    int updateByPrimaryKey(Coupon row);
}